<template>
	<view style="overflow-x: hidden;">
		<view class="nav-back">
			<top-heigth></top-heigth>
			<view class="content-box m-b16">
				<view class="time-top" style="padding: 30rpx 0 20rpx;">
					<view @click="titleChange(1)" :class="num == 1 ? 'title-font choose':'title-font'">全部</view>
					<view @click="titleChange(2)" :class="num == 2 ? 'title-font choose':'title-font'">待接单</view>
					<view @click="titleChange(3)" :class="num == 3 ? 'title-font choose':'title-font'">待服务</view>
					<view @click="titleChange(4)" :class="num == 4 ? 'title-font choose':'title-font'">已完成</view>
				</view>
			</view>
		</view>	
		<view v-if="list.length == 0" class="kong-box">
			<uv-empty mode="" text="还没有订单呦~" icon="/static/image/kong-order.png"></uv-empty>
		</view>
		
		<!-- -------- -->
		<view class="content-box" >
			<view v-for="item in list" class="public-box" @click="goDetail(item.id)" style="margin-bottom: 20rpx;">
				<view class="complaint-top">
					<view class="complaint-top-img">
						<view class="img"><image :src="item.tAppStaffVo.staffCover" mode=""></image></view>
						<view>技师：{{item.tAppStaffVo.staffName}}</view>
					</view>
					<view v-if="item.orderStatus == 0" class="complaint-top-r red">待接单</view>
					<view v-if="item.orderStatus == 1" class="complaint-top-r hui">待服务</view>
					<view v-if="item.orderStatus == 2" class="complaint-top-r orange">已完成</view>
					<view v-if="item.orderStatus == 3" class="complaint-top-r orange">申请退款</view>
					<view v-if="item.orderStatus == 4" class="complaint-top-r orange">退款成功</view>
					<view v-if="item.orderStatus == 5" class="complaint-top-r orange">退款失败</view>
					<view v-if="item.orderStatus == 6" class="complaint-top-r orange">技师拒单</view>
				</view>
				
				<view class="goods-box">
					<view class="goods">
						<view class="img-box">
							<image class="img" v-if="item.tAppServiceVo" :src="item.tAppServiceVo.serviceImage" mode=""></image>
						</view>
						<view class="goods-font">
							<view class="start-top">
								<h1 class="goods-h1 start-h1" v-if="item.tAppServiceVo">{{item.tAppServiceVo.serviceName}}</h1>
							</view>
							<view class="sale">预约时间：{{item.serviceReservedTime}}</view>
						</view>
					</view>
				</view>
				<view class="complaint-top">
					<view class="complaint-top-img">
						<view>地址：{{item.userAddress}}</view>
					</view>
				</view>
				<view class="goods-bottom m-t16">
					<view class="money-box">
						订单金额：
						<view class="red">
							<span class="goods-span-red">¥</span>{{item.orderAmount}}
						</view>
					</view>
					<view class="goods-bottom-r">
						<view v-if="item.orderStatus == 0" class="goods-bottom-but">接单</view>
						<!-- <view @click.stop="goEvaluate(1)" class="goods-bottom-but">评价</view> -->
					</view>
				</view>
			</view>
		</view>
		<view style="height: 60rpx;"></view>
		<!-- -------- -->
	</view>

</template>

<script>
	import TopHeigth from '@/components/TopHeigth.vue'
	
	export default {
		data() {
			return {
				userInfo: uni.getStorageSync('userInfo'),
				num:1,
				list:[],
			}
		},
		components: { TopHeigth },
		onShow() {
			this.titleChange(this.num)
		
		},
		onLoad(e){
			// console.log('用户点击取消',e);
			// if(e.num==4){
			//    this.titleChange(4)
			// }
		},
		methods: {
			getOrder(type) {
				uni.$u.http.post('/api/shop/v1_0/tAppOrderRCA/queryTAppOrder',{
						staffId:this.userInfo.id,
						//orderStatus:type,
						statusArray:type,
				}).then((res) => {
					this.list = res.aaData
				}) 
			},
			goDetail(id){
				uni.navigateTo({
					url: "/pages/order/orderDetail?id="+id
				})
			}, 
			goEvaluate(id){
				uni.navigateTo({
					url: "/pages/index/evaluate?id="+id
				})
			},
			titleChange(n){
				this.num = n
				if(n == 1){ //全部
					this.getOrder([0, 1, 2, 3, 4, 5])
				}
				if(n == 2){ //待接单
					this.getOrder([0])
				}
				if(n == 3){ //待服务
					this.getOrder([1])
				}
				if(n == 4){ //已完成
					this.getOrder([2])
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	@import "@/static/common/css/public.scss";
	@mixin flex($direction: row) {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: $direction;
	}
	.uv-nav-slot {
		@include flex;
		align-items: center;
		justify-content: space-between;
		border-width: 0.5px;
		border-radius: 100px;
		border-color: #dadbde;
		padding: 3px 7px;
		opacity: 0.8;
	}
	
	
	.complaint{
		.list{
			@include flex;
			align-items: center;
			justify-content:space-between;
			padding:28rpx 0;
			.go{
				width: 32rpx;
				height: 32rpx;
			}
			.list-l{
				@include flex;
				align-items: center;
				justify-content:flex-start;
				font-size: 30rpx;
				.icon{
					width: 40rpx;
					height: 40rpx;
				}
				span{
					margin-left: 16rpx;
				}
				
			}
		}
	}
	
	
	.money-box{
		@include flex;
		align-items: end;
		justify-content:flex-start;
		font-size: 24rpx;
		.red{
			color: #F82727;
			font-size: 34rpx;
			font-weight: bold;
			margin-right: 16rpx;
			span{
				font-size: 26rpx;
			}
		}
	}
	
	.complaint-top{
		@include flex;
		align-items: center;
		justify-content:space-between;
		.complaint-top-img{
			@include flex;
			align-items: center;
			justify-content:flex-start;
			font-size: 26rpx;
			.img{
				border-radius: 40rpx;
				overflow: hidden;
				font-weight: bold;
				color: #333;
				margin-right: 16rpx;
				image{
					width: 40rpx;
					height: 40rpx;
				}
			}
		}
		.complaint-top-r{
			font-size: 24rpx;
			color: #999;
		}
	}
	.goods-bottom{
		@include flex;
		align-items: center;
		justify-content:space-between;
		.goods-bottom-r{
			@include flex;
			align-items: center;
			justify-content:space-between;
		}
		.goods-bottom-but{
			width: 136rpx;
			height: 56rpx;
			line-height: 56rpx;
			font-size: 24rpx;
			color: #333;
			border: 2rpx solid #CBCBCB;
			border-radius:56rpx;
			text-align: center;
			margin-left: 16rpx;
		}
	}
	
	.time-top{
		@include flex;
		align-content: space-between;
		width: 100%;
		padding-top: 20rpx;
		.title-font{
			font-size: 30rpx;
			color: #333;
			text-align: center;
			padding-bottom: 16rpx;
			margin-right: 56rpx;
		}
		.choose{
			font-weight: bold;
			background: url("/static/image/title-line.png") no-repeat bottom center;
		}
	}
	
</style>
